import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import bread from '../../breadCrumn'
import { Breadcrumb } from 'antd'

import Style from './breadCrumb.css'

class breadCrumb extends PureComponent {
  constructor (props) {
    super(props)
    this.state = {
    }
  }

  breadClick (url) {
    if (url) {
      location.href = url
    }
  }

  render () {
    const { current } = this.props
    return (
      <div className={Style['bread-container']}>
        <Breadcrumb>
          {
            bread[current.path] && bread[current.path].map((item, index) => {
              return <Breadcrumb.Item key={item.name} onClick={() => this.breadClick(item.url)}>
                {
                  item.url ? <span className={Style['able-click']}>{item.name}</span> : item.name
                }
              </Breadcrumb.Item>
            })
          }</Breadcrumb>
        {/* <div className={Style['title']}>{current.name}</div> */}
      </div>
    )
  }
}

breadCrumb.propTypes = {
  current: PropTypes.any
}
export default breadCrumb
